Ok(ws)
}
- /// Creates a "tempoarary workspace" from one package which only contains
+ /// Creates a "temporary workspace" from one package which only contains
/// that package.
///
/// This constructor will not touch the filesystem and only creates an
}
}
+impl<'a, 'cfg> Members<'a, 'cfg> {
+ pub fn is_empty(self) -> bool {
+ self.count() == 0
+ }
+}
+
impl<'a, 'cfg> Iterator for Members<'a, 'cfg> {
type Item = &'a Package;
bail!("cannot specify both aggressive and precise simultaneously")
}
+ if ws.members().is_empty() {
+ bail!("you can't generate a lockfile for an empty workspace.")
+ }
+
let previous_resolve = match try!(ops::load_pkg_lockfile(ws)) {
Some(resolve) => resolve,
None => return generate_lockfile(ws),
assert_that(p.cargo("build").cwd(p.root().join("a")), execs().with_status(0));
}
+
+#[test]
+fn you_cannot_generate_lockfile_for_empty_workspaces() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [workspace]
+ "#)
+ .file("bar/Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+ "#)
+ .file("bar/src/main.rs", "fn main() {}");
+ p.build();
+
+ assert_that(p.cargo("update"),
+ execs().with_status(101)
+ .with_stderr("\
+error: you can't generate a lockfile for an empty workspace.
+"));
+}